//package com.ruoyi.web.controller.memberuser.service.impl;
//
//import java.math.BigDecimal;
//import java.math.RoundingMode;
//import java.util.Date;
//import java.util.List;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import com.ruoyi.web.controller.memberuser.domain.MemberUser;
//import com.ruoyi.web.controller.memberuser.domain.OrderCom;
//import com.ruoyi.web.controller.memberuser.mapper.MemberUserMapper;
//import com.ruoyi.web.controller.memberuser.mapper.OrderComMapper;
//import com.ruoyi.web.controller.memberuser.service.IMemberUserService;
//import com.ruoyi.web.controller.order.order.domain.OrderOrder;
//
//
///**
// * 会员管理Service业务层处理
// *
// * @author ruoyi
// * @date 2020-10-13
// */
//@Service
//public class MemberUserServiceImpl implements IMemberUserService
//{
//    @Autowired
//    private MemberUserMapper memberUserMapper;
//    @Autowired
//    private OrderComMapper orderComMapper;
//
//    @Override
//    @Transactional
//    public int handleOrderBack(OrderOrder order){
//        //查下单用户信息
//        MemberUser zfUser = memberUserMapper.selectMemberUserById(Long.parseLong(order.getUserId()));
//        //更新支付用户累计消费金额
//        zfUser.setCashMoney(zfUser.getCashMoney().subtract(order.getAllPrice()));
//        //更新支付用户累计节省金额
//        zfUser.setReduceMoney(zfUser.getReduceMoney().subtract(order.getReduceMoney()));
//        memberUserMapper.updateMemberUser(zfUser);
//        //根据订单ID查询返佣记录
//        OrderCom orderCom= orderComMapper.selectOrderComByOrderId(order.getId().toString());
//        if(orderCom == null){
//            return 1;
//        }
//        //有返佣记录,查上级用户改返佣记录状态
//        MemberUser syUser = memberUserMapper.selectMemberUserById(Long.parseLong(orderCom.getToUser()));
//        //更新上级用户累计返佣余额
//        syUser.setAllMoney(syUser.getAllMoney().subtract(order.getComMoney()));
//        //更新上级用户返佣余额
//        syUser.setMoney(syUser.getMoney().subtract(order.getComMoney()));
//        orderCom.setStatus(2);//更新返佣记录已退单
//        memberUserMapper.updateMemberUser(syUser);
//        return orderComMapper.updateOrderCom(orderCom);
//    }
//
//
//}
